package pakovan;

import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: Awake
 * Date: 31.01.12
 * Time: 11:00
 * To change this template use File | Settings | File Templates.
 */
abstract class Wing {
    public abstract int MaxSpeed();

    public abstract String MachineType();

    protected int maxSpeed;
    protected String machineType;
}

class Fighter extends Wing {
    Fighter(int maxSpeed, String machineType, String engineType, String mainWeapon) {
        this.maxSpeed = maxSpeed;
        this.machineType = machineType;
        this.engineType = engineType;
        this.mainWeapon = mainWeapon;
    }

    public int MaxSpeed() {
        return maxSpeed;
    }

    public String MachineType() {
        return machineType;
    }

    public String EngineType() {
        return engineType;
    }

    public String MainWeapon() {
        return mainWeapon;
    }

    private String engineType;
    private String mainWeapon;
}

class AirBus extends Wing {
    AirBus(int maxSpeed, String machineType, int passengers, String company) {
        this.maxSpeed = maxSpeed;
        this.machineType = machineType;
        this.passengers = passengers;
        this.company = company;
    }

    public int MaxSpeed() {
        return maxSpeed;
    }

    public String MachineType() {
        return machineType;
    }

    public int Passengers() {
        return passengers;
    }

    public String Company() {
        return company;
    }

    private int passengers;
    private String company;
}

class WingList {
    ArrayList<Wing> allWings = new ArrayList<Wing>();

    public void listSort() {
        Wing x;
        int i, j;
        for (i = 0; i < allWings.size(); i++) {
            x = allWings.get(i);
            for (j = i - 1; j >= 0 && allWings.get(j).MaxSpeed() > x.MaxSpeed(); j--)
                allWings.set(j + 1, allWings.get(j));
            allWings.set(j + 1, x);
        }
    }

    public boolean testSort() {
        boolean sorted = true;
        for (int i = 0; i < allWings.size() - 1; i++) {
            if (allWings.get(i).MaxSpeed() < allWings.get(i + 1).MaxSpeed()) {
                sorted = false;
                break;
            }
        }
        return sorted;
    }
}

class MyException extends Exception {
    private String exceptionName;

    MyException(String name) {
        exceptionName = name;
    }

    @Override
    public String toString() {
        return "MyException: " + exceptionName;
    }
}


